﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Pyramid.Extentions;

namespace Pyramid.Models
{
	/// <summary>
	///     系统用户
	/// </summary>
	public class Account
	{
		public int Id { get; set; }

		[Display(Name = "登录账号")]
		[MaxLength(20)]
		[Required]
		public string UserId { get; set; }

		[Display(Name = "登录密码")]
		[MaxLength(50)]
		[Required]
		public string Password { get; set; }

		[Display(Name = "用户姓名")]
		[MaxLength(20)]
		[Required]
		public string FullName { get; set; }

		[Display(Name = "邮箱")]
		[MaxLength(50)]
		[Required]
		public string Email { get; set; }

		[Display(Name = "手机")]
		[MaxLength(20)]
		[Required]
		public string Mobile { get; set; }

		[Display(Name = "用户类型")]
		public int UserType { get; set; }

		[NotMapped]
		public UserTypes UserTypeEnum
		{
			get { return (UserTypes) UserType; }
		}

		[NotMapped]
		public string UserTypeString{get { return UserTypeEnum.ToDescription(); }}

		/// <summary>
		/// 用户类型对应的扩展信息ID
		/// </summary>
		public int ExtInfoId { get; set; }

		[MaxLength(50)]
		[Display(Name = "相关名称")]
		public string ExtInfoName { get; set; }

		/// <summary>
		/// 用户拥有的角色
		/// </summary>
		public virtual ICollection<Role> Roles { get; set; }
	}
}